<?php
	
		class Dynamic_css extends CI_Controller {
		
				function __construct(){
						parent::__construct();
				}
				
				function index() {
						die('index');
				}
				
				function presets(){
						header("Content-type: text/css");
						
						$opts = read_options('', 'OBJECT'); 
						$data['styles'] = '';
						if(@$opts->font_family)
						{
								$fonts = preg_split('#\s*,\s*#is', $opts->font_family);
								$font_family = '';
								foreach($fonts as $font)
								{
										$quot = preg_match('#\s+#is', $font)?'"':'';
										$font_family .= ($font_family?',':'') . $quot . $font . $quot;
								}
								$data['styles'] .= "\n" . 'body { font-family: '.$font_family.'; }';
								if(@$opts->std_font_size && @$opts->std_font_unit)
								{
										$data['styles'] .= "\n" . 'body { font-size: '.$opts->std_font_size . $opts->std_font_unit.'; }';
								}
						}
						if(@$opts->hd_font_family)
						{
								$fonts = preg_split('#\s*,\s*#is', $opts->hd_font_family);
								$font_family = '';
								foreach($fonts as $font)
								{
										$quot = preg_match('#\s+#is', $font)?'"':'';
										$font_family .= ($font_family?',':'') . $quot . $font . $quot;
								}
								$data['styles'] .= "\n" . 'h1,h2,h3,h4,h5,h6 { font-family: '.$font_family.'; }';
								if(@$opts->hd_font_size && @$opts->hd_font_unit)
								{
										$data['styles'] .= "\n" . 'h1,h2,h3,h4,h5,h6 { font-size: '.$opts->hd_font_size . $opts->hd_font_unit.'; }';
								}
						}
						$this->load->view('dynamic_css', $data);
				}
				
		}
?>